<%@ taglib uri="/linuxbox/Calendar.tld" prefix="Calendar" %>

<table width="100%" border=0 cellpadding=0 cellspacing=0>
    <tr>
      <td><table cellpadding="3" cellspacing="0" border="0" width="100%">
        <tr bgcolor="#7EC1F3">
          <td align=left>
            <a href="<%=BoxStatic.servletDir%>BoxCalendarAction?t=<%
                Calendar tmpDay = (Calendar)currentDate.clone();
                tmpDay.add(Calendar.MONTH, -1);
                out.print(tmpDay.getTime().getTime());
              %>">
              <img SRC="<%=BoxStatic.imageDir%>cal_left.gif" WIDTH="11" HEIGHT="11" BORDER="0">Previous month</a>
          </td>
          <td align=center>
            <font face="Arial,Helvetica" SIZE="+1">
            <b><%=StringUtil.getDateTimeFormatString(sec.getTimeZone(), BoxStatic.MONTH_YEAR_FORMAT, currentDate.getTime())%>
            </b>
            </font>
          </td>
          <td align=right>
             <a href="<%=BoxStatic.servletDir%>BoxCalendarAction?t=<%
              tmpDay.add(Calendar.MONTH, 2);
              out.print(tmpDay.getTime().getTime());
            %>">Next month
              <img SRC="<%=BoxStatic.imageDir%>cal_right.gif" WIDTH="11" HEIGHT="11" BORDER="0"></a>
          </td>
        </tr>
      </table>
      </td>
    </tr>
    <tr>
      <td>
        <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr bgcolor="#cccccc">
          <td>
            <table CELLPADDING="2" CELLSPACING="1" BORDER="0" WIDTH="100%">
              <tr BGCOLOR="#7EC1F3">
                <th WIDTH="2%"><br></th>

<%
    for(int i = 1; i <=7; i++)
    {
%>
          <th ALIGN="left" WIDTH="14%"><font size="-1" face="Arial,Helvetica"><%=BoxStatic.shortWeekSymbols[i]%></font></th>
<%   }  %>
            </tr>
<%
    Calendar start = Calendar.getInstance(sec.getTimeZone());
    Calendar end = Calendar.getInstance(sec.getTimeZone());
    BoxCalHome.getMonthStartEnd(start,end,currentDate);

    long endTime = end.getTime().getTime();
    Calendar tmpWeekBegin = (Calendar) start.clone();
    tmpDay.setTime(start.getTime());
    int currentYear = currentDate.get(Calendar.YEAR);
    int currentMonth = currentDate.get(Calendar.MONTH);
    int currentDay = currentDate.get(Calendar.DAY_OF_YEAR);
    while(tmpWeekBegin.getTime().getTime() <= endTime)
    {
      tmpDay.setTime(tmpWeekBegin.getTime());
%>
            <tr BGCOLOR="#dcdcdc">
              <td width="1%" ALIGN="middle" ROWSPAN="2" VALIGN="top" BGCOLOR="#7EC1F3">
              <small><a href="<%=BoxStatic.servletDir%>BoxCalendarAction?v=week&t=<%=tmpWeekBegin.getTime().getTime()%>">week view</a> </small>
              </td>
<%
      for(int i = 1; i <= 7; i++)
      {
        if ( today.get(Calendar.DAY_OF_YEAR) == tmpDay.get(Calendar.DAY_OF_YEAR)
            && today.get(Calendar.YEAR) == tmpDay.get(Calendar.YEAR) )
        {
          out.print("<td ALIGN=\"left\" BGCOLOR=\"#ffffcc\">");
        }
        else
          out.print("<td ALIGN=\"left\">");

        if ( tmpDay.get(Calendar.MONTH) == currentMonth)
					out.print("<font COLOR=\"#777777\">");
				out.print("<a href=\"");
        out.print(BoxStatic.servletDir);
        out.print("BoxCalendarAction?v=day&t=");
        out.print(tmpDay.getTime().getTime());
        out.print("\">");
        out.print("<b>");
        out.print(tmpDay.get(Calendar.DATE));
        out.print("</b></a>&nbsp;&nbsp;&nbsp;");
        if ( tmpDay.get(Calendar.MONTH) == currentMonth)
					out.print("</font>");

				if (curID == curCalUserID)
        {
          out.print("<a href=\"");
          out.print(BoxStatic.servletDir);
          out.print("BoxCalendarAction?SubmitEdit=edit&t=");
          out.print(tmpDay.getTime().getTime());
          out.print("\"><font SIZE=\"1\">Add</font></a>");
        }
        out.print("</td>");

        tmpDay.add(Calendar.DATE,1);
      }//end for

      out.print("</tr> <tr BGCOLOR=\"#ffffff\">");

      tmpDay.setTime(tmpWeekBegin.getTime());
      for(int i = 1; i <= 7; i++)
      {
        boolean bHasItem = false;
        Iterator it = BoxCalHome.getAllDayEntries(curID, tmpDay,curCalUserID);
        if (it !=null && it.hasNext())
        {
          out.print("<td VALIGN=\"top\" BGCOLOR=\"white\">");
          bHasItem = true;
          while (it.hasNext())
          {
            BoxCalendarEntry bean = (BoxCalendarEntry) it.next();
            if ( bean != null )
            {
%>
              <font SIZE="2">
              <b>All day</b>
	            <Calendar:CalendarEntry timezone="<%=sec.getTimeZone()%>" shorttime="" viewerid="<%=curID%>" showtime="false" showdelete="false" calendarentry="<%=bean%>"/>
<%
            }
          }
        }

        it = BoxCalHome.getEntries(curID, tmpDay, curCalUserID);
        if (it !=null && it.hasNext())
        {
          if (!bHasItem)
          {
            bHasItem = true;
            out.print("<td VALIGN=\"top\" BGCOLOR=\"white\">");
          }
          while (it.hasNext())
          {
            BoxCalendarEntry bean = (BoxCalendarEntry) it.next();
            if ( bean != null )
            {
%>
              <font SIZE="2">
	            <Calendar:CalendarEntry timezone="<%=sec.getTimeZone()%>"  viewerid="<%=curID%>" shorttime="true" showtime="true" showdelete="false" calendarentry="<%=bean%>"/>
              </font><br>
<%
            }
          }
        }
        if (bHasItem)
          out.print("<br></td>");
        else
          out.print("<td VALIGN=\"top\" BGCOLOR=\"#eeeeee\"><br></td>");
        tmpDay.add(Calendar.DATE,1);
      }//end for
      tmpWeekBegin.add(Calendar.DATE,7);
    } //end while
%>

          </table>
          </td>
        </tr>
      </table>
      </td>
    </tr>
    <tr>
      <td align="right"><font color="#ffffff">___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
      ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
      ___ ___ ___ ___ ___ ___ </font></td>
    </tr>
  </table>

